Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix nginx 404 handling for a Single Page Application (SPA) by reorganizing the proxy_intercept_errors directive and modifying the error_page configuration.
Key Changes:
- Moved
proxy_intercept_errors on;from global scope into thelocation /block to scope error interception to frontend routes only - Changed
error_page 404 = /index.html;toerror_page 404 /index.html;(removed the=operator)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| proxy_intercept_errors on; | ||
| # when the proxied frontend responds 404, rewrite internally to /index.html | ||
| error_page 404 = /index.html; | ||
| error_page 404 /index.html; |
There was a problem hiding this comment.
Removing the = sign from the error_page directive changes the behavior in a potentially problematic way.
With error_page 404 = /index.html;, nginx returns a 200 OK status with the index.html content, which is correct for valid client-side routes.
With error_page 404 /index.html;, nginx returns a 404 status code while serving the index.html content, which is incorrect for legitimate SPA routes (e.g., /about, /profile). Browsers and search engines will see these as failed requests.
Consider reverting to error_page 404 = /index.html; to properly handle client-side routes.
| error_page 404 /index.html; | |
| error_page 404 = /index.html; |
No description provided.